import pygame
from pygame.sprite import Sprite

class Alien(Sprite):
	"""docstring for Alien"""
	def __init__(self, screen,settings):
		super(Alien, self).__init__()
		self.screen = screen
		self.settings = settings

		self.image = pygame.image.load('images/alien.png')
		self.rect = self.image.get_rect()
		#外星人最初出现文字
		self.rect.x = 0
		self.rect.y = 0

	def blitme(self):
		self.screen.blit(self.image,self.rect)

	def update(self):
		self.rect.x += 1*self.settings.aliens_direct
		#if self.rect.x+self.rect.width>self.settings.screen_width:
			#self.rect.x = 0

	#检查是否需要变向
	def check_edge(self):
		screen_rect = self.screen.get_rect()  
		if self.rect.right >= screen_rect.right:
			return True 
		elif self.rect.left <= 0:
			return True